home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#02 (Apr85-Jul85)
/
modula 2
/
modula Vol. 1 #6
/
Matmul.MOD
< prev
Wrap
Text File
|
1985-03-04
|
2KB
|
83 lines
MODULE Matmul;
FROM InOut IMPORT ReadCard, WriteCard, WriteString, WriteLn;
FROM Terminal IMPORT ClearScreen;
FROM RealInOut IMPORT ReadReal, GWriteReal;
FROM QuickDrawTypes IMPORT Rect, GrafPtr, Str255, LongCard;
FROM ToolBoxTypes IMPORT WindowPtr, WindowRecord;
FROM Strings IMPORT StrModToMac;
FROM SYSTEM IMPORT ADDRESS;
CONST CX = 355B; QuickDrawModNum = 1; ToolBoxModNum = 2;
TYPE Ptr = ADDRESS;
VAR i,j,k : CARDINAL;
sum,p,q : REAL;
a : ARRAY [1..20] OF ARRAY [1..30] OF REAL;
b : ARRAY [1..30] OF ARRAY [1..20] OF REAL;
c : ARRAY [1..30] OF ARRAY [1..30] OF REAL;
Wbounds : Rect;
Wtitle : Str255;
Wnew : WindowPtr;
WrefCon, behind, OnHeap: LongCard;
PROCEDURE SetPort (port : WindowPtr);
CODE CX; QuickDrawModNum; 4 END SetPort;
PROCEDURE PortSize (width, height : INTEGER);
CODE CX; QuickDrawModNum; 8 END PortSize;
PROCEDURE TextFont (font : INTEGER);
CODE CX; QuickDrawModNum; 32 END TextFont;
PROCEDURE TextSize (size : INTEGER);
CODE CX; QuickDrawModNum; 35 END TextSize;
PROCEDURE NewWindow (wStorage : Ptr; boundsRect : Rect;
title : Str255; visible : BOOLEAN;
theProc:INTEGER; behind : WindowPtr;
goAwayFlag:BOOLEAN; refCon:LongCard) : WindowPtr;
CODE CX; ToolBoxModNum; 50 END NewWindow;
PROCEDURE DrawGrowIcon (theWindow : WindowPtr);
CODE CX; ToolBoxModNum; 64 END DrawGrowIcon;
PROCEDURE SelectWindow (theWindow : WindowPtr);
CODE CX; ToolBoxModNum; 56 END SelectWindow;
BEGIN
WITH WrefCon DO h := 0; l := 0 END;
WITH behind DO h := 65535; l := 65535 END;
WITH OnHeap DO h := 0; l := 0 END;
WITH Wbounds DO top := 50; left := 20; bottom := 300; right := 500 END;
StrModToMac (Wtitle, "Demo Window"); TextFont(0); TextSize(12);
Wnew := NewWindow(Ptr(OnHeap),Wbounds,Wtitle,TRUE,0,
WindowPtr(behind),TRUE,WrefCon);
SetPort(Wnew); SelectWindow(Wnew); DrawGrowIcon(Wnew);
PortSize(464,234); ClearScreen; TextFont(3); TextSize(9);
WriteString("Initialization values for a: "); ReadReal(p);
WriteString(", and b: "); ReadReal(q); WriteLn;
FOR i:= 1 TO 20 DO
FOR j:= 1 TO 30 DO
a[i][j] := p; b[j][i] := q
END
END;
WriteString ("Initialization done."); WriteLn;
FOR i:= 1 TO 30 DO
FOR j:= 1 TO 30 DO
sum := 0.0;
FOR k := 1 TO 20 DO sum:=sum + a[k][i]*b[j][k] END;
c[i][j] := sum
END
END;
WriteString ("Multiplication completed."); WriteLn;
WriteString (" C[15,16] = "); GWriteReal (c[15][16],10);
ReadReal(p)
END Matmul.